package com.ruoyi.gzmx_tag_history.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gzmx_tag_history.domain.Gzmx_tag_history;
import com.ruoyi.gzmx_tag_history.service.IGzmx_tag_historyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 采集数据历史数据Controller
 * 
 * @author ruoyi
 * @date 2022-08-02
 */
@Controller
@RequestMapping("/gzmx_tag_history/gzmx_tag_history")
public class Gzmx_tag_historyController extends BaseController
{
    private String prefix = "gzmx_tag_history/gzmx_tag_history";

    @Autowired
    private IGzmx_tag_historyService gzmx_tag_historyService;

    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:view")
    @GetMapping()
    public String gzmx_tag_history()
    {
        return prefix + "/gzmx_tag_history";
    }

    /**
     * 查询采集数据历史数据列表
     */
    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Gzmx_tag_history gzmx_tag_history)
    {
        startPage();
        List<Gzmx_tag_history> list = gzmx_tag_historyService.selectGzmx_tag_historyList(gzmx_tag_history);
        return getDataTable(list);
    }

    /**
     * 导出采集数据历史数据列表
     */
    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:export")
    @Log(title = "采集数据历史数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Gzmx_tag_history gzmx_tag_history)
    {
        List<Gzmx_tag_history> list = gzmx_tag_historyService.selectGzmx_tag_historyList(gzmx_tag_history);
        ExcelUtil<Gzmx_tag_history> util = new ExcelUtil<Gzmx_tag_history>(Gzmx_tag_history.class);
        return util.exportExcel(list, "采集数据历史数据数据");
    }

    /**
     * 新增采集数据历史数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存采集数据历史数据
     */
    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:add")
    @Log(title = "采集数据历史数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Gzmx_tag_history gzmx_tag_history)
    {
        return toAjax(gzmx_tag_historyService.insertGzmx_tag_history(gzmx_tag_history));
    }

    /**
     * 修改采集数据历史数据
     */
    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        Gzmx_tag_history gzmx_tag_history = gzmx_tag_historyService.selectGzmx_tag_historyById(id);
        mmap.put("gzmx_tag_history", gzmx_tag_history);
        return prefix + "/edit";
    }

    /**
     * 修改保存采集数据历史数据
     */
    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:edit")
    @Log(title = "采集数据历史数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Gzmx_tag_history gzmx_tag_history)
    {
        return toAjax(gzmx_tag_historyService.updateGzmx_tag_history(gzmx_tag_history));
    }

    /**
     * 删除采集数据历史数据
     */
    @RequiresPermissions("gzmx_tag_history:gzmx_tag_history:remove")
    @Log(title = "采集数据历史数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gzmx_tag_historyService.deleteGzmx_tag_historyByIds(ids));
    }
}
